<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:gs="http://java.sun.com/jsf/composite/gs"
	template="/WEB-INF/templates/default.xhtml">
	<ui:define name="menu">
		<ui:include src="/protected/user/menu.xhtml" >
			<ui:param name="activeMenu" value="internacion" />
		</ui:include>		
	</ui:define>	
	<ui:define name="breadcrumb">
		<ui:include src="breadcrumbIndex.xhtml" />
	</ui:define>
	<ui:define name="content">	
		<h:form id="form-search" styleClass="well form-horizontal">
			<div class="control-group">
				<h:outputLabel value=""  
					styleClass="control-label"/>
				<gs:buttonSearch bean="#{internacionSeachBean}"/>
			</div>
		</h:form>

		<h:form id="form-content">
			<rich:dataTable value="#{internacionSeachBean.dataModel}"
				styleClass="table table-bordered table-striped table-condensed"
				columnClasses="pf-sc-1,pf-sc-2,pf-sc-3,pf-search-col-4,pf-sc-5,pf-sc-6,pf-sc-7,pf-search-col-8"
				keepSaved="true" id="resultTable" var="result" rows="20">

				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.internacionId}" 
		                    	render="resultTable"
		                        action="#{internacionSeachBean.sort}">
		                        <f:param name="sortProperty" value="id" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{internacionSeachBean.sortsOrders['id']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{internacionSeachBean.sortsOrders['id']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>	
					</f:facet>
					<h:link outcome="edit" value="#{result.id}">
						<f:param name="id" value="#{result.id}"/>
					</h:link>
					
				</h:column>

				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.internacionFecha}" 
		                    	render="resultTable"
		                        action="#{internacionSeachBean.sort}">
		                        <f:param name="sortProperty" value="fecha" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{internacionSeachBean.sortsOrders['fecha']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{internacionSeachBean.sortsOrders['fecha']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>	
					</f:facet>
					<h:outputText value="#{result.fecha}" >
						<f:convertDateTime dateStyle="medium" />
					</h:outputText>	
				</h:column>

				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.internacionEstado}" 
		                    	render="resultTable"
		                        action="#{internacionSeachBean.sort}">
		                        <f:param name="sortProperty" value="estado" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{internacionSeachBean.sortsOrders['estado']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{internacionSeachBean.sortsOrders['estado']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>	
					</f:facet>
					<h:outputText value="#{messages[result.estado.label]}" />
				</h:column>

				<h:column>
					<f:facet name="header">
						<h:panelGroup styleClass="search-column" layout="block">
		                	<a4j:commandLink execute="@this" 
		                		value="#{messages.internacionMotivoInternacion}" 
		                    	render="resultTable"
		                        action="#{internacionSeachBean.sort}">
		                        <f:param name="sortProperty" value="motivoInternacion" />
							</a4j:commandLink>

							<h:panelGroup rendered="#{internacionSeachBean.sortsOrders['motivoInternacion']=='ascending'}">
								<i class="icon-arrow-up"></i>
							</h:panelGroup>
							<h:panelGroup rendered="#{internacionSeachBean.sortsOrders['motivoInternacion']=='descending'}">
								<i class="icon-arrow-down"></i>
							</h:panelGroup>
						</h:panelGroup>	
					</f:facet>
					<h:outputText value="#{result.motivoInternacion}" />
				</h:column>

				<f:facet name="footer">
					<rich:dataScroller id="scroller" renderIfSinglePage="false"
						stepControls="show"
						fastControls="hide"
						styleClass="pagination"
						for="resultTable" maxPages="10">
					</rich:dataScroller>
				</f:facet>								
			</rich:dataTable>
			
			<div class="form-actions">
				<h:link outcome="create"
					style="margin-left:5px;"
					styleClass="btn btn-info">
					<i class="icon-file" title="#{messages.internacionCreate}"></i>				
					<h:outputText value=" #{messages.internacionCreate}" />
				</h:link>			
			</div>
		</h:form>		
	</ui:define>
</ui:composition>